<?php

namespace app\admin\controller\finance;

use app\admin\model\UM as UM;
use app\admin\service\BillStatisticsService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * BillStatistics 控制器
 * Class BillStatistics
 * @package app\admin\controller\finance;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 */
class BillStatistics
{
    // 请求参数
    private Request $request;

    // service
    private BillStatisticsService $service;

    public function __construct(Request $request, BillStatisticsService $billStatisticsService)
    {
        $this->request = $request;
        $this->service = $billStatisticsService;
    }

    /**
     * 详情
     * @return ApiResponse
     * @url /finance/bill_statistics/read
     */
    public function read(?UM $user): ApiResponse
    {
        $request = $this->request;

        $memberId = $request->param('memberId');
        $type = $request->param('type');
        $billType = $request->param('billType');
        $accountType = $request->param('accountType');
        $startTime = $request->param('startTime');
        $endTime = $request->param('endTime');
        $kw = $request->param('kw');

        return ApiResponse::success($this->service->read($user, $memberId, $type, $billType, $accountType, $startTime, $endTime, $kw));
    }
}
